home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 June: Reference Library / Dev.CD Jun 99 RL Disk 1.toast / Technical Documentation / Develop / develop Issue 28 / develop Issue 28 code / MacApp Debugging / TwistDownLists / UVolume.h < prev    next >
Encoding:
Text File  |  1996-07-15  |  4.3 KB  |  107 lines  |  [TEXT/MPS ]

  1. //----------------------------------------------------------------------------------------
  2. // UVolume.h
  3. // ETO20 MacApp 3.3.1, MPW 3.4.1
  4. // Copyright ©1996 Conrad Kopala
  5. // Twist Down Lists version 2.0a0 7/15/96
  6. //----------------------------------------------------------------------------------------
  7.  
  8. #ifndef __UVOLUME__
  9. #define __UVOLUME__
  10.  
  11. // MacApp
  12. #ifndef __UOBJECT__
  13. #include "UObject.h"
  14. #endif
  15.  
  16. // Toolbox
  17. #ifndef __ALIASES__
  18. #include "Aliases.h"
  19. #endif
  20.  
  21. #ifndef __STANDARDFILE__
  22. #include "StandardFile.h"
  23. #endif
  24.  
  25. //ANSI
  26. //None
  27.  
  28.  
  29. // UVolume parallels UFile. It would have been preferable to use TFile but that
  30. // doesn't work. 
  31.  
  32. // TApplication::CanOpenDocument compares aFile -> fFileType with the fileTypes 
  33. // the application is allowed to open. In this case, the application is allowed to 
  34. // open files of type 'disk'. When a file is specified, using one or another of the 
  35. // TFile::Specifies methods, StandardFileReply and SFReply which these methods rely 
  36. // on do not return a fileType of 'disk.' In other words, itsReply.sfType does not 
  37. // return 'disk' but 'garbage' instead. The net effect is that CanOpenDocument 
  38. // returns false and nothing happens. One could, of course, override CanOpenDocument 
  39. // and make it return TRUE.
  40. //
  41. // But, TFile::SpecifyWithAlias uses TFile::GetFinderInfo to get the fileType
  42. // using FSpGetFInfo and since junk is returned, SpecifyWithAlias defaults to a
  43. // fileType of 'TEXT' and again, nothing happens. I wanted the user to be able to 
  44. // drop a volume on the application icon or its alias and open the volume.
  45. //
  46. // Finally, TFile contains methods that are not appropriate to a volume. For example,
  47. // CreateFile, CreateDataFork, CreateResourceFork, OpenFile, etc. I don't think it is
  48. // good design to drag along all those methods, so subclassing TFile is not a good
  49. // idea. If TFile were subclassed, many methods, for safety's sake, would have to be 
  50. // overridden to do nothing or you would have to research each one to make sure nothing
  51. // bad would happen.
  52. //
  53. // When working within a framework such as MacApp, the only appropriate ways of modifying
  54. // its behavior are to subclass and override or to create a new object. One thing you really
  55. // don't want to do is modify the framework code. In this case, it seemed best to create a 
  56. // new object, TVolume.
  57. //
  58. // By choosing to create TVolume, methods of TApplication were affected. Specifically, 
  59. // methods involved with opening old files: DoMakeFile, ChooseFile, CanOpenDocument, and
  60. // OpenOld. But, they are based on TFile and I needed methods based on TVolume. I could 
  61. // have put the substitute methods DoMakeVolume, ChooseVolume, CanOpenVolume, and
  62. // OpenVolume in TTwistDownApp but, for one thing, I wanted to keep them together. 
  63. // For another, to avoid confusion, I wanted their names to use the word, volume instead of
  64. // file. Therefore, I created MVolumeBasedApp and used multiple inheritance. 
  65. //
  66. // See UVolumeBasedApp.h for more.
  67. //----------------------------------------------------------------------------------------
  68. // TVolume
  69. //----------------------------------------------------------------------------------------
  70.  
  71. class TVolume : public TObject
  72. {
  73.     MA_DECLARE_CLASS;
  74.     
  75. public:
  76.  
  77. FSSpec fFileSpec;                // volume/ directory/filename
  78. OSType fFileType;                // file type
  79. OSType fCreator;                // creator ID
  80.  
  81. TVolume::TVolume();    
  82. void TVolume::IVolume(OSType itsCreator);
  83. virtual ~TVolume();
  84.  
  85. Boolean TVolume::IsHFSVolume();
  86. void TVolume::Specify(const FSSpec& theVolume);
  87. void TVolume::SpecifyWithStandardFileReply(const StandardFileReply& itsReply);
  88. OSErr TVolume::SpecifyWithSFReply(const SFReply& itsReply);
  89. OSErr TVolume::SpecifyWithAlias(AliasHandle alias);
  90. OSErr TVolume::SpecifyWithTrio(short volRefNum, long dirID, const CStr63& name);
  91. OSErr TVolume::GetAlias(AliasHandle& alias);
  92. OSErr TVolume::GetCatInfo(CInfoPBRec& cInfo);
  93. void TVolume::GetName(CStr31& name);
  94. short TVolume::GetVolRefNum();
  95. Boolean TVolume::IsSameVolume(TVolume* aVolume);
  96. };
  97.  
  98. //----------------------------------------------------------------------------------------
  99. // Global function declarations
  100. //----------------------------------------------------------------------------------------
  101.  
  102. extern TVolume* NewVolume(OSType itsCreator);
  103.     // A convenience function. Create a TVolume, initialize it, and return a reference to
  104.   // it. Signals Failure if it cannot allocate the object.
  105.  
  106.  
  107. #endif